package net.neptech.config;

import net.neptech.dto.order.DelayMessage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.nio.charset.StandardCharsets;

@Configuration
public class RedisConfig2 {
    @Bean
    public RedisTemplate<String, DelayMessage> delayMessageRedisTemplate(RedisConnectionFactory cf) {
        RedisTemplate<String, DelayMessage> t = new RedisTemplate<>();
        t.setConnectionFactory(cf);
        t.setKeySerializer(new StringRedisSerializer(StandardCharsets.UTF_8));
        t.setValueSerializer(new FastJson2JsonRedisSerializer<>());
        t.setHashKeySerializer(new StringRedisSerializer(StandardCharsets.UTF_8));
        t.setHashValueSerializer(new FastJson2JsonRedisSerializer<>());
        t.afterPropertiesSet();
        return t;
    }


}
